var heartCheck = {
    timeout : 3000,
    timeoutObj : null,
    serverTimeoutObj : null,
    start : function () {
        console.log('start');
        var self = this;
        this.timeoutObj && clearTimeout(this.timeoutObj);
        this.serverTimeoutObj && clearTimeout(this.serverTimeoutObj);
        this.timeoutObj = setTimeout(function () {
            // 这里发送一个心跳,后端接收后,返回一个心跳消息,
            console.log('timeoutObj ... ');

            self.serverTimeoutObj = setTimeout(function () {
                console.log('serverTimeoutObj ... ');
            },self.timeout);
        },this.timeout);

    }
};

heartCheck.start();